package com.jzr.board.db1.mapper;

import com.jzr.board.db1.vo.NurseLevelSumVo;
import com.jzr.board.db1.vo.NurseServiceSumVo;
import com.jzr.board.db1.vo.NurseServiceVo;
import com.jzr.board.db1.vo.OutlayTypeSumVo;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDate;
import java.util.List;

public interface MyWorkViewMapper {
    //住院总数
    @Select("select count(1) as qty from t_bed b where b.`status`=1 and dept_code=#{deptCode}")
    Integer getTotalInPat(String deptCode);

    //入院数
    @Select("select count(1) as qty from t_patient p where dept_code=#{deptCode} and status=1 and in_time>=#{beginTime} and in_time<#{endTime}")
    Integer getInQty(String deptCode, LocalDate beginTime, LocalDate endTime);

    //出院数
    @Select("select count(1) as qty from t_patient p where dept_code=#{deptCode} and status=3 and out_time>=#{beginTime} and out_time<#{endTime}")
    Integer getOutQty(String deptCode, LocalDate beginTime, LocalDate endTime);

    //重症病人数
    @Select("select count(1) as qty from t_patient where dept_code=#{deptCode} and status=1 and severe_care=1")
    Integer getSevereCareQty(String deptCode);

    //费用类别统计
    List<OutlayTypeSumVo> getOutlayTypeSum(String deptCode);

    //手术数
    @Select("select count(1) as qty from t_operation where dept_code=#{deptCode} and status=1 and op_date>=#{beginDate} and op_date<#{endDate}")
    Integer getOperationQty(String deptCode, LocalDate beginDate, LocalDate endDate);

    //转床数
    @Select("select count(1) as qty from t_adm_tran where from_dept=#{deptCode} and op_type=3 and op_date>=#{beginDate} and op_date<#{endDate}")
    Integer getTranBedQty(String deptCode,LocalDate beginDate, LocalDate endDate);

    //转入数
    @Select("select count(1) as qty from t_adm_tran where dest_dept=#{deptCode} and op_type=2 and op_date>=#{beginDate} and op_date<#{endDate}")
    Integer getTranInQty(String deptCode,LocalDate beginDate, LocalDate endDate);

    //转出数
    @Select("select count(1) as qty from t_adm_tran where from_dept=#{deptCode} and dest_dept<>#{deptCode} and op_type=2 and op_date>=#{beginDate} and op_date<#{endDate}")
    Integer getTranOutQty(String deptCode,LocalDate beginDate, LocalDate endDate);

    //转床列表
    List<String> getTranBedList(String deptCode,LocalDate beginDate, LocalDate endDate);

    //护理级别统计
    List<NurseLevelSumVo> getNurseLevelSum(String deptCode);

    //护理信息统计
    List<NurseServiceSumVo> getNurseServiceSum();
    List<NurseServiceVo> getNurseService(String deptCode);
}
